package org.itboys.core.controller.web.company;

import com.wordnik.swagger.annotations.Api;
import org.itboys.admin.tools.AdminSessionHolder;
import org.itboys.core.common.SundayCommonConstants;
import org.itboys.core.entity.mongo.SundayMember;
import org.itboys.core.entity.mysql.tray.SundayTrayModel;
import org.itboys.core.service.mongo.web.SundayMemberService;
import org.itboys.core.service.mysql.web.SundayTrayModelService;
import org.itboys.framework.spring.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者：zzq
 * 时间：2018/12/17
 * 描述：供应商托盘
 */
@Controller
@RequestMapping("/sunday/web/company/tray")
@Api(value = "tray", description = "托盘")
public class SundayCompanyTrayController extends BaseController {
    @Autowired
    private SundayMemberService memberService;
    @Autowired
    private SundayTrayModelService modelService;
    /**
     * 主页
     *
     * @param request
     * @param model
     * @return
     */
    @RequestMapping("/index")
    public String index(
            HttpServletRequest request,
            Model model
    ) {
        SundayMember member=memberService.getMemberByUserId(AdminSessionHolder.getAdminUserId());
        model.addAttribute("member", member);
        Map<String,Object> param=new HashMap<String,Object>();
        param.clear();
        param.put("isDeleted", SundayCommonConstants.NO);
        List<SundayTrayModel> models = modelService.select(param);
        model.addAttribute("models", models);
        return "/sunday/company/tray/index";
    }



}
